<template>
  <div style="width: 400px; height: 200px; background: rgb(32, 154, 211)">
    <div id="container" ref="highchartsRef" style="height: 200px"></div>
  </div>
</template>

<script>
import Highcharts from 'highcharts/highstock';
// import Highcharts3D from 'highcharts/highcharts-3d';
// Highcharts3D(Highcharts);
export default {
  name: 'Highcharts',
  components: {},
  props: {},
  data() {
    return {
      options: {
        chart: {
          type: 'pie',
          options3d: {
            enabled: true,
            alpha: 45,
          },
        },
        // title: {
        //   text: '简数科技每周水果消耗量',
        // },
        // subtitle: {
        //   text: 'Highcharts 中的3D环形图',
        // },
        plotOptions: {
          pie: {
            innerSize: 100,
            depth: 45,
            dataLabels: {
              distance: 100, //控制饼图外面的线的长短,为负数时文本内容在饼图内部
              enabled: false, //控制引导线的长短b
            },
          },
        },
        series: [
          {
            name: '货物金额',
            data: [
              ['香蕉', 8],
              ['猕猴桃', 3],
              ['桃子', 1],
              ['橘子', 6],
              ['苹果', 8],
              ['梨', 4],
              ['柑橘', 4],
              ['橙子', 1],
              ['葡萄 (串)', 1],
            ],
          },
        ],
      },
    };
  },
  computed: {},
  watch: {
    // option(val) {
    //   HighCharts.chart('container', this.options);
    // },
  },
  created() {},
  mounted() {
    console.log(window);
    console.log(Highcharts);
    // window.onresize('resize', this.reflow);
    // window.onresize = function () {
    //    this.reflow
    //   };
    // 图表初始化函数
    Highcharts.chart('container', this.options);

    // highcharts 自适应
    // setTimeout(() => {
    //   this.$refs.highchartsRef.chart.reflow();
    // }, 500);
    setTimeout(() => {
      console.log(231231232132432423);
      const event = document.createEvent("HTMLEvents");
      event.initEvent("resize", true, true);
      window.dispatchEvent(event);
    }, 100);
     // let chart = Highcharts.chart('plan-echarts', options);
    // chart.reflow();
  },
  methods: {
    //  reflow() {
    //   HighCharts.chart('container', this.options).reflow()
    // },
  },
};
</script>

<style scoped>
::v-deep .highcharts-title {
  display: none !important;
} 
::v-deep .highcharts-background {
  display: none !important;
}
::v-deep .highcharts-credits {
  display: none !important;
}
::v-deep .highcharts-color-2 {
  color: red;
}
</style>
